home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / lib / mntlib44.zoo / mntlib / purec / Makefile < prev    next >
Encoding:
Makefile  |  1994-03-01  |  17.8 KB  |  632 lines

  1. ### Makefile for MiNT Library for Pure C and Turbo C
  2. ### hohmuth 19 Feb 1993
  3. ###
  4. ### This makefile needs GNU make.
  5. ###
  6. ### This makefile is pretty tough.. Make sure your make has a large stack!
  7. ### (The MiNT library's standard stack size (8K) is _not_ enough!)
  8.  
  9. ###
  10. ### begin of configuration section
  11. ###
  12.  
  13. # TURBOC= yes if you still use Turbo C.
  14. # If you do so, I strongly suggest upgrading to Pure C.
  15. # Comment this out if you use Pure C.
  16.  
  17. #TURBOC=        yes
  18.  
  19. # COMPILERDIR= the main directory of your Turbo/Pure C installation
  20. # As file names in rules may not contain colons (`:'), this path
  21. # name should _not_ contain a TOS-style drive specification (like "c:").
  22. # If you define TOSIFY_COMMANDS below, this path will be automatically 
  23. # tosified.
  24.  
  25. #COMPILERDIR=    /dev/g/turboc
  26. COMPILERDIR=    /dev/d/pc
  27.  
  28. # BINDIR= where your compiler's tools (pcc.ttp, plink.ttp etc.) reside
  29.  
  30. #BINDIR=        $(COMPILERDIR)
  31. BINDIR=        $(COMPILERDIR)/bin
  32.  
  33. # LIBDIR= where to search for the compiler's libraries. Some of them are
  34. # linked into the MiNT library.
  35.  
  36. LIBDIR=        $(COMPILERDIR)/lib
  37.  
  38. # COMPILERINCDIR= where to find your compiler's includes, especially
  39. # float.h and math.h.
  40. # This is only needed during "make install-includes".
  41.  
  42. COMPILERINCDIR=    $(COMPILERDIR)/include
  43.  
  44. # INCLUDEDIR= where your MiNT library's include files (mntinc) reside.
  45. # If you define TOSIFY_NAMES below, this is path will be automatically 
  46. # tosified for the compiler's -I switch.
  47.  
  48. INCLUDEDIR=    /dev/z/src/lib/include
  49.  
  50. # OSBINDLIB= the location of the osbind library by Ole Arndt und 
  51. # Ulf Moeller, if you have it.  This library replaces our TOS bindings.
  52. # If you use Turbo C, and don't have `awk', you _should_ get this library.
  53. # If you don't have it, you need to have `awk'.  (we need to hack our
  54. # TOS bindings) 
  55. # For Pure C users: You don't need to have this library.
  56. # Comment this out, if you don't have the osbind library.
  57.  
  58. #OSBINDLIB=    $(LIBDIR)/osbind.lib
  59.  
  60. # INSTALLDIR= the directory you want to have the MiNT library installed to.
  61. # This is only needed during "make install".
  62.  
  63. INSTALLDIR=    $(LIBDIR)
  64.  
  65. # COMMONDIR= where the main bulk of the library source resides
  66.  
  67. COMMONDIR=    ..
  68.  
  69. # ASSERTIONS= yes if you want to activate the library's calls to assert().
  70. # Comment this out if you don't.
  71.  
  72. #ASSERTIONS=    yes
  73.  
  74. # DEBUGINFO= yes, if you want your libraries created with debug info.
  75. # Comment this out if you don't.
  76.  
  77. #DEBUGINFO=    yes
  78.  
  79. # PCREL= yes, if you want all sub-routine calls to be PC relative.
  80. # This can cause problems with bigger projects, however.
  81. # Comment this out if you prefer absolute calls to sub-routines.
  82.  
  83. #PCREL= yes
  84.  
  85. # TOSIFY_NAMES= yes if the compiler's tools (pcc, plink etc.) don't 
  86. # understand Unix-like path names.
  87. # Comment this out if your compiler _does_ understand names like "/dev/c/foo".
  88.  
  89. TOSIFY_NAMES=    yes
  90.  
  91. # TOSIFY_COMMANDS= yes if your shell (see SHELL below) wants path names
  92. # in TOS form (i.e. does not understand unix compatible file names like
  93. # "/dev/c/foo"). Mupfel wants this.
  94. # Comment this out if your shell groks names like "/dev/c/foo".
  95. # NOTE: your versions of rm, cp, etc. _should_ understand
  96. #       unix-like names
  97.  
  98. #TOSIFY_COMMANDS=    yes
  99.  
  100. # sh_backslash= the string that should be passed to the shell as a single
  101. # backslash character. This depends on your shell (whether your
  102. # shell needs backslashes escaped with another backslash, as do most
  103. # unix-like shells). On contrast, Mupfel wants only one backslash, as well
  104. # as the shell that comes with `elvis'.
  105.  
  106. sh_backslash=    \\
  107. #sh_backslash=    \$(nothing)
  108.  
  109. # SHELL, RM, CP, INSTALL_DATA, AWK, ECHO: edit to suite your taste
  110. # These programs _should_ understand unix-like path names (like "/dev/c/foo").
  111. # INSTALL_DATA is only needed during "make install" and "make install-includes".
  112. # AWK is only needed when using Turbo C without the osbind library (see
  113. # explanation on OSBINDLIB above)
  114. # ECHO is only needed with Turbo C.
  115. #
  116. # all of these programs should understand the ARGV scheme.
  117.  
  118. SHELL=        /bin/sh            # a bourne shell
  119. #SHELL=        /usr/local/bin/bash    # GNU bash
  120. #SHELL=        c:/usr/gemini/1.89/mupfel.ttp # Mupfel 1.89 (don't try 1.21)
  121. #SHELL=        c:/bin/shell.ttp    # simple shell (from `elvis' distribution)
  122. #SHELL=                    # no shell at all (works only with Pure C)
  123.  
  124. RM=        rm
  125. CP=        cp
  126. AWK=        awk
  127. ECHO=        echo
  128. INSTALL_DATA=    cp
  129. #INSTALL_DATA=    install -m 644
  130.  
  131. ###
  132. ### end of configuration section
  133. ###
  134.  
  135. ### the compiler programs, and what flags they need
  136.  
  137. ifdef TOSIFY_NAMES
  138.   DIRSEP=    $(sh_backslash)
  139. else
  140.   DIRSEP=    /
  141. endif
  142.  
  143. ifdef TURBOC
  144.   CC :=        $(BINDIR)/tcc.ttp -W
  145.   AS :=        $(BINDIR)/mas.ttp
  146.   LD :=        $(BINDIR)/tlink.ttp
  147. else
  148.   CC :=        $(BINDIR)/pcc.ttp -W
  149.   AS :=        $(BINDIR)/pasm.ttp
  150.   LD :=        $(BINDIR)/plink.ttp
  151. endif
  152.  
  153. ifdef TOSIFY_COMMANDS
  154.   tosify_name := $(CC)
  155.   include tosify.mak
  156.   CC := $(tosify_name)
  157.  
  158.   tosify_name := $(AS)
  159.   include tosify.mak
  160.   AS := $(tosify_name)
  161.  
  162.   tosify_name := $(LD)
  163.   include tosify.mak
  164.   LD := $(tosify_name)
  165. endif
  166.  
  167. ifdef DEBUGINFO
  168.   CCSYMFLAGS=    -Y
  169.   ifdef TURBOC
  170.     ASSYMFLAGS=
  171.   else
  172.     ASSYMFLAGS=    -Y
  173.   endif
  174.   LDSYMFLAGS=    -G -L -Y
  175. else
  176.   CCSYMFLAGS=
  177.   ASSYMFLAGS=
  178.   LDSYMFLAGS=    -G
  179. endif
  180.  
  181. ifdef PCREL
  182.   CCRELFLAGS=
  183. else
  184.   CCRELFLAGS=    -P
  185. endif
  186.  
  187. MAKEOBJ=    -J
  188.  
  189. ifdef ASSERTIONS
  190.   CCDEBUGDEFS=
  191. else
  192.   CCDEBUGDEFS=    -DNDEBUG
  193. endif
  194.  
  195. INCSPEC :=    $(INCLUDEDIR)
  196.  
  197. # tosify the include specification
  198. ifdef TOSIFY_NAMES
  199.   tosify_name := $(INCSPEC)
  200.   include tosify.mak
  201.   INCSPEC := $(tosify_name)
  202. endif
  203.  
  204. CCINCFLAGS=    -I$(INCSPEC)
  205.  
  206. # with Turbo C, we need to work around its missing ARGV capability
  207. ifdef TURBOC
  208.   ARGV_WORKAROUND=    yes
  209. else
  210.   ARGV_WORKAROUND=
  211. endif
  212.  
  213. ### default flags to compiler, linker, assembler
  214.  
  215. CCFLAGS=    $(CCINCFLAGS) $(CCSYMFLAGS) $(CCRELFLAGS) $(CCDEBUGDEFS)
  216. ASFLAGS=    $(ASSYMFLAGS)
  217. LDFLAGS=    $(LDSYMFLAGS)
  218.  
  219. ### what to build
  220.  
  221. MINTLIB=    mintlib.lib
  222. MATHLIB=    mintflt.lib
  223. FPUMATHLIB=    mint881.lib
  224. STARTUPOBJ=    crt0.o
  225. ALLOCAOBJ=    alloca.o
  226. FPUALLOCAOBJ=    falloca.o
  227.  
  228. MYTOSLIB=    myosbind.lib
  229.  
  230. DIST_MATHLIB=    d_flt.lib
  231. DIST_FPUMATHLIB=    d_881.lib
  232.  
  233. ifdef TURBOC
  234.   ALL=        $(MINTLIB) $(MATHLIB) $(STARTUPOBJ) $(ALLOCAOBJ)
  235.   BINDIST=    $(MINTLIB) $(DIST_MATHLIB) $(STARTUPOBJ) $(ALLOCAOBJ)
  236. else
  237.   ALL=        $(MINTLIB) $(MATHLIB) $(STARTUPOBJ) $(ALLOCAOBJ) \
  238.     $(FPUMATHLIB) $(FPUALLOCAOBJ)
  239.   BINDIST=    $(MINTLIB) $(DIST_MATHLIB) $(STARTUPOBJ) $(ALLOCAOBJ) \
  240.     $(DIST_FPUMATHLIB) $(FPUALLOCAOBJ)
  241. endif
  242.  
  243. .PHONY:        all
  244. all:        $(ALL)
  245.  
  246. .PHONY:        bindist
  247. bindist:    $(BINDIST)
  248.  
  249. ### things we link from the compiler's distribution
  250.  
  251. ifdef TURBOC
  252.   CCFLOATLIB :=    $(LIBDIR)/tcfltlib.lib
  253. else
  254.   CCFLOATLIB :=    $(LIBDIR)/pcfltlib.lib
  255.   CC881LIB :=    $(LIBDIR)/pc881lib.lib
  256. endif
  257.  
  258. CCFLOATLIBSPEC :=    $(CCFLOATLIB)
  259. CC881LIBSPEC :=    $(CC881LIB)
  260.  
  261. # tosify the library specifications, if nessecary
  262. ifdef TOSIFY_NAMES
  263.   tosify_name := $(CCFLOATLIBSPEC)
  264.   include tosify.mak
  265.   CCFLOATLIBSPEC := $(tosify_name)
  266.  
  267.   tosify_name := $(CC881LIBSPEC)
  268.   include tosify.mak
  269.   CC881LIBSPEC := $(tosify_name)
  270. endif
  271.  
  272. ### which OS bindings library to link
  273.  
  274. BUILD_MYTOSLIB_DEP :=
  275.  
  276. # the osbind library replaces our tos library.
  277. ifdef OSBINDLIB
  278.   TOSLIB :=    $(OSBINDLIB)
  279. else
  280.   ifdef TURBOC
  281.     TOSLIB :=    $(MYTOSLIB)
  282.  
  283.     # used as a file dependency for $(MINTLIB)
  284.     BUILD_MYTOSLIB_DEP :=    $(MYTOSLIB)
  285.   else
  286.     TOSLIB :=
  287.   endif
  288. endif
  289.  
  290. TOSLIBSPEC :=    $(TOSLIB)
  291.  
  292. # tosify the library specification, if nessecary
  293. ifdef TOSIFY_NAMES
  294.   tosify_name := $(TOSLIBSPEC)
  295.   include tosify.mak
  296.   TOSLIBSPEC := $(tosify_name)
  297. endif
  298.  
  299. ### how to build MINTLIB
  300.  
  301. COMMONSRC :=    a64l.c abort.c abs.c access.c alarm.c alphasor.c atexit.c \
  302.   atoi.c atol.c bblink.c bcmp.c binmode.c bsearch.c calloc.c \
  303.   cfgetisp.c cfgetosp.c cfsetisp.c cfsetosp.c chdir.c \
  304.   chmod.c chown.c clock.c close.c closedir.c console.c crtinit.c ctermid.c \
  305.   ctime.c ctype.c defmode.c \
  306.   doprnt.c do_lock.c do_stat.c dup.c dup2.c eprintf.c \
  307.   execl.c execle.c execp.c execv.c execve.c \
  308.   fclose.c fcntl.c fdopen.c fflush.c \
  309.   fgetc.c fgetpos.c fgets.c filbuf.c findfile.c flock.c fopen.c \
  310.   fopen_i.c fopenp.c fork.c fprintf.c \
  311.   fputc.c fputs.c fread.c freopen.c frwbin.c \
  312.   fscanf.c fseek.c fsetpos.c fstat.c ftell.c ftw.c \
  313.   fungetc.c fwrite.c getbuf.c getcwd.c \
  314.   getdtabl.c getenv.c getegid.c geteuid.c getgid.c getgroup.c \
  315.   gethostn.c getlogin.c getopt.c getpages.c \
  316.   getpass.c getpid.c getppid.c getpw.c \
  317.   getrusag.c gets.c getuid.c getw.c getwd.c \
  318.   grp.c heapbase.c ic.c ident.c ig.c \
  319.   il.c inistack.c initsig.c inode.c ioctl.c \
  320.   ip.c isatty.c isctty.c iw.c kill.c killpg.c \
  321.   l64a.c labs.c ldiv.c link.c localtim.c lockf.c lseek.c lstat.c \
  322.   ltoa.c main.c malloc.c memccpy.c \
  323.   memchr.c memcmp.c mkdir.c mkfifo.c mknod.c mktemp.c nice.c nlist.c \
  324.   obstack.c open.c opendir.c \
  325.   pause.c perror.c pipe.c pgrp.c popen.c \
  326.   printf.c psignal.c putenv.c puts.c \
  327.   qsort.c raise.c \
  328.   rand.c random.c read.c readdir.c realloc.c \
  329.   regexp.c regsup.c rename.c rewind.c rewinddi.c rmdir.c \
  330.   sbrk.c scandir.c scanf.c seekdir.c select.c \
  331.   setbuf.c setegid.c seteuid.c setlocal.c \
  332.   setregid.c setreuid.c setrlimi.c setgid.c setuid.c \
  333.   setvbuf.c sgtty.c sigactio.c sigblock.c siglist.c signal.c sleep.c \
  334.   spawn.c spawnve.c spawnvp.c sprintf.c sscanf.c stat.c statfs.c stksiz.c \
  335.   strcat.c strchr.c strcmp.c strcoll.c strcpy.c strcspn.c strdup.c \
  336.   strerror.c strftime.c stricmp.c strlen.c strlwr.c strncat.c strncmp.c \
  337.   strncpy.c strnicmp.c strpbrk.c strrchr.c strrev.c strspn.c strstr.c \
  338.   strtok.c strtol.c strtoul.c strupr.c symlink.c sysconf.c system.c \
  339.   sysvar.c tcattr.c tcbreak.c tcdrain.c tcflow.c tcflush.c tcpgrp.c \
  340.   telldir.c textio.c thread.c time.c timeoday.c times.c tmpfile.c tmpnam.c \
  341.   toxxx.c truncate.c ttyname.c uidgid.c uname.c unlink.c unx2dos.c utime.c \
  342.   utmp.c vfprintf.c vfscanf.c vprintf.c vscanf.c wait.c \
  343.   wait3.c waitpid.c wcmb.c \
  344.   wcscat.c wcscmp.c wcscpy.c wcslen.c wnull.c write.c wtmp.c 
  345. COMMONSRC := $(addprefix $(COMMONDIR)/,$(COMMONSRC))
  346.  
  347. SRC :=        bzero.c memset.c alloca2.c \
  348.   bcopy.s linea.s setjmp.s vfork.s
  349.  
  350. ifndef TOSLIB
  351.   # no tos bindings library -- link our bindings.
  352.   SRC :=    $(SRC) osbind.s bios.s xbios.s gemdos.s mintbind.s
  353.   bios.o xbios.o gemdos.o mintbind.o:    osmacros.s
  354. endif
  355.  
  356. ifdef TURBOC
  357.   SUPPORTSRC=    fpuinit.c stkover.s
  358. else
  359.   SUPPORTSRC=    fpuinit.c stkover.s pclong.s 
  360. endif
  361.  
  362. MINTSRC=    $(COMMONSRC) $(SUPPORTSRC) $(SRC)
  363.  
  364. MINTOBJ :=    $(patsubst %.c,%.o,$(MINTSRC))
  365. MINTOBJ :=    $(patsubst %.s,%.o,$(MINTOBJ))
  366.  
  367. ifdef ARGV_WORKAROUND
  368.   MINTLIB_CMD=    $(basename $(MINTLIB)).cmd
  369.   MINTLIB_PARAM=    -C=$(MINTLIB_CMD)
  370.   MINTLIB_DEP=    $(MINTOBJ) $(MINTLIB_CMD)
  371.  
  372.   $(MINTLIB_CMD):
  373.     -$(RM) -f $@
  374.     $(ECHO) -n $(subst /,$(DIRSEP),$(MINTOBJ)) > $@
  375. else
  376.   MINTLIB_PARAM=    $(subst /,$(DIRSEP),$(MINTOBJ))
  377.   MINTLIB_DEP=    $(MINTOBJ)
  378. endif
  379.  
  380. ifneq (,$(wildcard $(firstword $(MINTSRC))))
  381.   $(MINTLIB):    $(MINTLIB_DEP) $(BUILD_MYTOSLIB_DEP)
  382.     $(LD) $(MAKEOBJ) $(LDFLAGS) -O=$@ $(MINTLIB_PARAM) $(TOSLIBSPEC)
  383. else
  384. # if the source is not present (binary distribution), we just check for
  385. # the presence of the library.
  386.   $(MINTLIB): ;
  387. endif
  388.  
  389. %.o:        %.s
  390.     $(AS) $(ASFLAGS) -O=$(subst /,$(DIRSEP),$@) $(subst /,$(DIRSEP),$<)
  391.  
  392. %.o:        %.c
  393.     $(CC) $(CCFLAGS) -D__NO_FLOAT__ \
  394.       -O$(subst /,$(DIRSEP),$@) $(subst /,$(DIRSEP),$<)
  395.  
  396. $(COMMONDIR)/crtinit.o:    $(COMMONDIR)/crtinit.c
  397.     $(CC) -P -S- -T- $(CCFLAGS) -D__NO_FLOAT__ \
  398.       -O$(subst /,$(DIRSEP),$@) $(subst /,$(DIRSEP),$<)
  399.  
  400. $(COMMONDIR)/main.o:    $(COMMONDIR)/main.c
  401.     $(CC) -P $(CCFLAGS) -D__NO_FLOAT__ \
  402.       -O$(subst /,$(DIRSEP),$@) $(subst /,$(DIRSEP),$<)
  403.  
  404. $(COMMONDIR)/qsort.o:    $(COMMONDIR)/qsort.c
  405.     $(CC) -S -T $(CCFLAGS) -D__NO_FLOAT__ \
  406.       -O$(subst /,$(DIRSEP),$@) $(subst /,$(DIRSEP),$<)
  407.  
  408. $(COMMONDIR)/thread.o:    $(COMMONDIR)/thread.c
  409.     $(CC) -P -S- $(CCFLAGS) -D__NO_FLOAT__ \
  410.       -O$(subst /,$(DIRSEP),$@) $(subst /,$(DIRSEP),$<)
  411.  
  412. setjmp.o:    setjmp.s
  413.     $(AS) $(ASFLAGS) -D=FPU=0 \
  414.       -O=$(subst /,$(DIRSEP),$@) $(subst /,$(DIRSEP),$<)
  415.  
  416. ### how to build MYTOSLIB, our own tos bindings library
  417.  
  418. ifdef TURBOC
  419.   # for Turbo C, this is quite tricky.  Turbo's assembler MAS doesn't
  420.   # understand the directives ".MODULE" and ".ENDMOD", but we still want
  421.   # one module per binding.  That's why we use awk to cut modules
  422.   # from the source files and build one object file per binding.
  423.  
  424.   MYBINDSRC :=    bios.s xbios.s gemdos.s mintbind.s
  425.   
  426.   # we make a list of object file we want to build and re-instantiate `make'.
  427.   # in the new instance, we include that list into our makefile
  428.   MAKEINCL :=    myosbind.mak
  429.  
  430.   ifndef MAKEINCL_OK
  431.     $(MAKEINCL):    $(MYBINDSRC)
  432.     $(AWK) 'BEGIN { FS = " |:|\t" ; printf "MYBINDOBJ := " } /^\.MODULE/ { printf "%s.o ", $$2 }' \
  433.       $^ > $@
  434.  
  435.     $(MYTOSLIB):    $(MYBINDSRC) osmacros.s osbind.s $(MAKEINCL)
  436.     $(MAKE) $(MYTOSLIB) MAKEINCL_OK=yes
  437.   else
  438.  
  439.     # this should define MYBINDOBJ
  440.     include $(MAKEINCL)
  441.  
  442.     $(MYBINDOBJ):    %.o:    $(MYBINDSRC) osmacros.s
  443.     -$(RM) -f temp.s
  444.     $(AWK) -v name=$(patsubst %.o,%,$@) -f filter.awk $(MYBINDSRC) > temp.s
  445.     $(AS) $(ASFLAGS) -O=$@ temp.s
  446.  
  447.     ifdef ARGV_WORKAROUND
  448.       MYTOSLIB_CMD=    $(basename $(MYTOSLIB)).cmd
  449.       MYTOSLIB_PARAM=    -C=$(MYTOSLIB_CMD)
  450.       MYTOSLIB_DEP=    $(MYBINDOBJ) $(MYTOSLIB_CMD)
  451.     
  452.       $(MYTOSLIB_CMD):    $(MAKEINCL)
  453.     -$(RM) -f $@
  454.     $(ECHO) -n $(MYBINDOBJ) > $@
  455.     else
  456.       MYTOSLIB_PARAM=    $(MYBINDOBJ)
  457.       MYTOSLIB_DEP=    $(MYBINDOBJ)
  458.     endif
  459.  
  460.     $(MYTOSLIB):    osbind.o $(MYTOSLIB_DEP)
  461.     $(LD) $(MAKEOBJ) $(LDFLAGS) -O=$@ osbind.o $(MYTOSLIB_PARAM)
  462.  
  463.   endif
  464. else
  465.   # with Pure C, everything's so much easier :-)
  466.   # however, it's unlikely that you'll need this.
  467.  
  468.   MYTOSSRC :=    osbind.s bios.s xbios.s gemdos.s mintbind.s
  469.   MYTOSOBJ :=    $(patsubst %.s,%.o,$(MYTOSSRC))
  470.  
  471.   bios.o xbios.o gemdos.o mintbind.o:    osmacros.s
  472.  
  473.   $(MYTOSLIB):    $(MYTOSOBJ)
  474.     $(LD) $(MAKEOBJ) $(LDFLAGS) -O=$@ $^
  475.  
  476. endif
  477.  
  478. ### how to build MATHLIB
  479.  
  480. MATHOBJ=    m_main.o m_doprnt.o m_scanf.o m_difftime.o
  481.  
  482. ifneq ($(DIST_MATHLIB),$(wildcard $(DIST_MATHLIB)))
  483.   $(MATHLIB):    $(MATHOBJ) # $(CCFLOATLIB)
  484.     $(LD) $(MAKEOBJ) $(LDFLAGS) -O=$@ \
  485.       $(subst /,$(DIRSEP),$(MATHOBJ)) $(CCFLOATLIBSPEC)
  486. else
  487. # link with the bindist's rudimentary math library, if it exists
  488.   $(MATHLIB):    $(DIST_MATHLIB) # $(CCFLOATLIB)
  489.     $(LD) $(MAKEOBJ) $(LDFLAGS) -O=$@ \
  490.       $(DIST_MATHLIB) $(CCFLOATLIBSPEC)
  491. endif
  492.  
  493. ifneq (,$(wildcard $(patsubst m_%.o,$(COMMONDIR)/%.c,$(firstword $(MATHOBJ)))))
  494.   $(DIST_MATHLIB):    $(MATHOBJ)
  495.     $(LD) $(MAKEOBJ) $(LDFLAGS) -O=$@ \
  496.       $(subst /,$(DIRSEP),$(MATHOBJ))
  497. else
  498. # if the source is not present (binary distribution), we just check for
  499. # the presence of the distributable library.
  500.   $(DIST_MATHLIB): ;
  501. endif
  502.  
  503. m_%.o:        $(COMMONDIR)/%.c
  504.     $(CC) -T- $(CCFLAGS) \
  505.       -O$(subst /,$(DIRSEP),$@) $(subst /,$(DIRSEP),$<)
  506.  
  507. m_main.o:    $(COMMONDIR)/main.c
  508.     $(CC) -T- -P $(CCFLAGS) \
  509.       -O$(subst /,$(DIRSEP),$@) $(subst /,$(DIRSEP),$<)
  510.  
  511. ### how to build FPUMATHLIB
  512.  
  513. FPUMATHOBJ =    f_main.o f_doprnt.o f_scanf.o f_difftime.o f_setjmp.o
  514.  
  515. ifneq ($(DIST_FPUMATHLIB),$(wildcard $(DIST_FPUMATHLIB)))
  516.   $(FPUMATHLIB):    $(FPUMATHOBJ) # $(CC881LIB)
  517.     $(LD) $(MAKEOBJ) $(LDFLAGS) -O=$@ \
  518.       $(subst /,$(DIRSEP),$(FPUMATHOBJ)) $(CC881LIBSPEC)
  519. else
  520. # link with the bindist's rudimentary math library, if it exists
  521.   $(FPUMATHLIB):    $(DIST_FPUMATHLIB) # $(CC881LIB)
  522.     $(LD) $(MAKEOBJ) $(LDFLAGS) -O=$@ \
  523.       $(DIST_FPUMATHLIB) $(CC881LIBSPEC)
  524. endif
  525.  
  526. ifneq (,$(wildcard $(patsubst f_%.o,$(COMMONDIR)/%.c,$(firstword $(FPUMATHOBJ)))))
  527.   $(DIST_FPUMATHLIB):    $(FPUMATHOBJ)
  528.     $(LD) $(MAKEOBJ) $(LDFLAGS) -O=$@ \
  529.       $(subst /,$(DIRSEP),$(FPUMATHOBJ))
  530. else
  531. # if the source is not present (binary distribution), we just check for
  532. # the presence of the distributable library.
  533.   $(DIST_FPUMATHLIB): ;
  534. endif
  535.  
  536. f_%.o:        $(COMMONDIR)/%.c
  537.     $(CC) -T- -8 $(CCFLAGS) \
  538.       -O$(subst /,$(DIRSEP),$@) $(subst /,$(DIRSEP),$<)
  539.  
  540. f_main.o:    $(COMMONDIR)/main.c
  541.     $(CC) -T- -8 -P $(CCFLAGS) \
  542.       -O$(subst /,$(DIRSEP),$@) $(subst /,$(DIRSEP),$<)
  543.  
  544. f_setjmp.o:    setjmp.s
  545.     $(AS) $(ASFLAGS) -D=FPU=1 \
  546.       -O=$(subst /,$(DIRSEP),$@) $(subst /,$(DIRSEP),$<)
  547.  
  548. ### how to build the startup code
  549.  
  550. STARTUPSRC=    crt0.s
  551.  
  552. ifneq (,$(wildcard $(STARTUPSRC)))
  553.   $(STARTUPOBJ):    $(STARTUPSRC)
  554.     $(AS) $(ASFLAGS) -O=$(subst /,$(DIRSEP),$@) $(subst /,$(DIRSEP),$<)
  555. else
  556. # if the source is not present (binary distribution), we just check for
  557. # the presence of the object files.
  558.   $(STARTUPOBJ): ;
  559. endif
  560.  
  561. ### how to build the fast versions of alloca()
  562.  
  563. ALLOCASRC=    alloca.s
  564.  
  565. ifneq (,$(wildcard $(ALLOCASRC)))
  566.   $(ALLOCAOBJ):    $(ALLOCASRC)
  567.     $(AS) $(ASFLAGS) -D=STACKCH=1 -D=FPU=0 \
  568.       -O=$(subst /,$(DIRSEP),$@) $(subst /,$(DIRSEP),$<)
  569.  
  570.   $(FPUALLOCAOBJ):    $(ALLOCASRC)
  571.     $(AS) $(ASFLAGS) -D=STACKCH=1 -D=FPU=1 \
  572.       -O=$(subst /,$(DIRSEP),$@) $(subst /,$(DIRSEP),$<)
  573. else
  574. # if the source is not present (binary distribution), we just check for
  575. # the presence of the object files.
  576.   $(ALLOCAOBJ): ;
  577.   $(FPUALLOCAOBJ): ;
  578. endif
  579.  
  580. ### how to build the test program
  581.  
  582. .PHONY:        test
  583. test:        test.tos
  584.  
  585. ifdef TURBOC
  586.   CCSTDLIB :=    $(LIBDIR)/tcstdlib.lib
  587.   CCSTDLIBSPEC :=    $(CCSTDLIB)
  588.   ifdef TOSIFY_NAMES
  589.     tosify_name :=    $(CCSTDLIBSPEC)
  590.     include tosify.mak
  591.     CCSTDLIBSPEC :=    $(tosify_name)
  592.   endif
  593.  
  594.   TEST_LINKLIBS=    $(CCSTDLIBSPEC)
  595. else
  596.   TEST_LINKLIBS=
  597. endif
  598.  
  599. test.tos:    $(MINTLIB) $(STARTUPOBJ) test.o
  600.     $(LD) $(LDFLAGS) -S=0 -O=$@ $(STARTUPOBJ) test.o \
  601.       $(MINTLIB) $(TEST_LINKLIBS)
  602.  
  603. test.o:        test.c
  604.     $(CC) -S $(CCFLAGS) -O$@ $<
  605.     
  606. ### how to make clean
  607.  
  608. .PHONY:        clean
  609. clean:
  610.     -$(RM) -f $(COMMONDIR)/*.o
  611.     -$(RM) -f *.o
  612.     -$(RM) -f *.cmd
  613.     -$(RM) -f temp.s test.tos
  614.  
  615. .PHONY:        realclean
  616. realclean:    clean
  617.     -$(RM) -f *.lib
  618. ifdef MAKEINCL
  619.     -$(RM) -f $(MAKEINCL)
  620. endif
  621.  
  622. ### how to install
  623.  
  624. .PHOHY:        install
  625. install:    $(ALL)
  626.     $(INSTALL_DATA) $(ALL) $(INSTALLDIR)
  627.  
  628. .PHONY:        install-includes
  629. install-includes:
  630.     $(INSTALL_DATA) $(COMPILERINCDIR)/float.h $(INCLUDEDIR)/tcfloat.h
  631.     $(INSTALL_DATA) $(COMPILERINCDIR)/math.h $(INCLUDEDIR)/tcmath.h
  632.